﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DotNetNinjaLibrary.Utils;

namespace DotNetNinjaLibrary.Tests.Utils
{
	[TestClass]
	public class InteresectionHelperTests
	{
		[TestMethod]
		public void IntersectsWithOneDimensionTest()
		{
			Assert.IsTrue(IntersectionHelper.IntersectsWith(0, 1, 0, 1));
			Assert.IsTrue(IntersectionHelper.IntersectsWith(0, 1, 0, 5));
			Assert.IsTrue(IntersectionHelper.IntersectsWith(0, 10, 1, 5));
			Assert.IsTrue(IntersectionHelper.IntersectsWith(2, 4, 1, 5));

			Assert.IsFalse(IntersectionHelper.IntersectsWith(0, 1, 1, 5));
			Assert.IsFalse(IntersectionHelper.IntersectsWith(5, 10, 1, 5));
			Assert.IsFalse(IntersectionHelper.IntersectsWith(5, 10, 11, 15));
			Assert.IsFalse(IntersectionHelper.IntersectsWith(15, 20, 11, 14));
		}

		[TestMethod]
		public void IntersectsWithTwoDimensionsTest()
		{
			Assert.IsTrue(IntersectionHelper.IntersectsWith(
				new Basics.Point(0,0), new Basics.Size(2, 2), 
				new Basics.Point(0,0), new Basics.Size(2, 2)));

			Assert.IsTrue(IntersectionHelper.IntersectsWith(
				new Basics.Point(0, 0), new Basics.Size(4, 4),
				new Basics.Point(1, 1), new Basics.Size(2, 2)));

			Assert.IsTrue(IntersectionHelper.IntersectsWith(
				new Basics.Point(3, 0), new Basics.Size(1, 4),
				new Basics.Point(1, 1), new Basics.Size(3, 2)));

			Assert.IsFalse(IntersectionHelper.IntersectsWith(
				new Basics.Point(6, 0), new Basics.Size(1, 4),
				new Basics.Point(1, 1), new Basics.Size(4, 2)));

			Assert.IsFalse(IntersectionHelper.IntersectsWith(
				new Basics.Point(1, 4), new Basics.Size(4, 4),
				new Basics.Point(1, 1), new Basics.Size(4, 2)));

			Assert.IsFalse(IntersectionHelper.IntersectsWith(
				new Basics.Point(5, 5), new Basics.Size(4, 4),
				new Basics.Point(1, 1), new Basics.Size(3, 2)));
		}
	}
}
